package com.atguigu.Spring5demo3.Testbean;/*
@author joker
@create 2022-03-19 15:06
untitled
*/

import com.atguigu.Spring5demo3.config.SpringConfig;
import com.atguigu.Spring5demo3.service.UserService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class testbean {

    @Test
    public void testService(){

        ApplicationContext context = new ClassPathXmlApplicationContext("Componentbean.xml");
        UserService userService = context.getBean("userService", UserService.class);
        userService.add();
    }

    @Test
    public void testService2(){
        ApplicationContext context = new ClassPathXmlApplicationContext("Componentbean.xml");
        UserService aa = context.getBean("userService",UserService.class);
        aa.add();
    }
    @Test
    /**完全注解开发,没有xml文件*/
    public void testService3(){
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
        UserService aa = context.getBean("userService",UserService.class);
        aa.add();
    }
}
